@extends('home.parent')
@section('title','会员列表')
@section('head_js')
@endsection
@section('head_css')
<link rel="stylesheet" href="{{ asset('/css/dataTables.bootstrap.css') }}">
<link rel="stylesheet" href="{{ asset('/css/toggleButtonsMain.css') }}">
@endsection
@section('content')
  <div class="content-wrapper">
    <section class="content-header">
      <h1>
        会员拓客列表
        <small></small>
      </h1>
      <ol class="breadcrumb">
        <li><a href="{{URL('admin')}}"><i class="fa fa-dashboard"></i> 首页</a></li>
        <li class="active">会员列表</li>
      </ol>
    </section>
    <section class="content">
      <div class="row">
        <div class="col-xs-12">
          <div class="box">
            <div class="box-header">
              <div class="form-inline pull-right">
                <fieldset>
                  <div class="input-group input-group-sm">
                    <span class="input-group-addon"><strong>用户名</strong></span>
                    <input type="text" class="form-control" id="user_name">
                  </div>
                  <div class="input-group input-group-sm">
                    <span class="input-group-addon"><strong>所属合伙人</strong></span>
                    <input type="text" class="form-control" id="pName">
                  </div>
                  <div class="input-group input-group-sm">
                    <div class="input-group-btn">
                      <button type="button"  class="btn btn-primary" onclick="searchData()"><i class="fa fa-search"></i></button>
                    </div>
                  </div>
                </fieldset>
              </div>
            </div>
            <!-- /.box-header -->
            <div class="box-body">
              <table id="data_list" class="table table-bordered table-striped">
                <thead>
                  <tr>
                    <th>所属合伙人</th>
                     <th>创建者</th>
                    <th>用户名</th>
                      <th>公司</th>
                    <th>行业</th>
                    <th>联系人</th>
                    <th>联系方式</th>
                    <th>创建时间</th>
                    <th>状态</th>
                    <th>操作</th>
                  </tr>
                </thead>
                <tbody>
                </tbody>
                <tfoot>
                  <tr>
                      <th>所属合伙人</th>
                      <th>创建者</th>
                      <th>用户名</th>
                      <th>公司</th>
                      <th>行业</th>
                      <th>联系人</th>
                      <th>联系方式</th>
                      <th>创建时间</th>
                      <th>状态</th>
                      <th>操作</th>
                  </tr>
                </tfoot>
              </table>
            </div>
          </div>
        </div>
      </div>
    </section>
  </div>
  <style>
    #showuser table {
      border-collapse: collapse;
      color: #777;
      width: 100%;
    }

    #showuser table tr th, #showuser table tr td {
      padding: 10px;
      border: 1px solid #f8f8f8;
      white-space: nowrap
    }

    #showuser table tbody tr:hover {
      background: #f3f3f3;
    }

    #showuser table thead tr {
      background: #f0f0f0;
    }

    #showuser .more {
      text-align: center;
      padding: 10px 0;
    }

    #showuser .more span {
      cursor: pointer;
    }

    #showuser div button {
      padding-right: 20px;
      margin-right: 15px;
    }
  </style>
  <div id="showuser" style="display:none;color:#777;padding:10px 20px 0 20px;">
    <div class="stable-header">
      <div class="form-inline pull-right">
        <fieldset>
          <div class="input-group">
							<span class="input-group-addon">
								<strong>活动名称</strong>
							</span>
            <input type="text" class="form-control" name="title">
          </div>
          <div class="input-group">
            <button type="button" class="btn btn-primary" onclick="showuserall()">
              <i class="fa fa-search"></i>
            </button>
          </div>
        </fieldset>
      </div>
      <div style="clear:both;"></div>
    </div>
    <table>
      <thead>
      <tr>
        <td>所属会员</td>
        <td>头像</td>
        <td>昵称</td>
        <td>手机号</td>
        <td>活动标题</td>
        <td>地区</td>
        <td>性别</td>
        <td>时间</td>
       </tr>
      </thead>
      <tbody></tbody>
    </table>
    <div class="more"></div>
    <input type="hidden" name="kid">
    <input type="hidden" name="nextPage">
  </div>
{{--------------------------------------------------------------------------视频弹窗                                                              --}}
  <style>
    #showvideo table {
      border-collapse: collapse;
      color: #777;
      width: 100%;
    }

    #showvideo table tr th, #showvideo table tr td {
      padding: 10px;
      border: 1px solid #f8f8f8;
      white-space: nowrap
    }

    #showvideo table tbody tr:hover {
      background: #f3f3f3;
    }

    #showvideo table thead tr {
      background: #f0f0f0;
    }

    #showvideo .more {
      text-align: center;
      padding: 10px 0;
    }

    #showvideo .more span {
      cursor: pointer;
    }

    #showvideo div button {
      padding-right: 20px;
      margin-right: 15px;
    }

  </style>
  <div id="showvideo" style="display:none;color:#777;padding:10px 20px 0 20px;">
    <div class="stable-header">
      <div class="form-inline pull-right">
        <fieldset>
          <div class="input-group">
							<span class="input-group-addon">
								<strong>视频标签</strong>
							</span>
            <input type="text" class="form-control" name="title">
          </div>
          <div class="input-group">
            <button type="button" class="btn btn-primary" onclick="showvideoall()">
              <i class="fa fa-search"></i>
            </button>
          </div>
        </fieldset>
      </div>
      <div style="clear:both;"></div>
    </div>
    <table>
      <thead>
      <tr>
        <td>所属会员</td>
        <td>标签</td>
        <td>封面</td>
        <td>视频</td>
        <td>更新时间</td>
        <td>状态</td>
        <td>操作</td>
         </tr>
      </thead>
      <tbody></tbody>
    </table>
    <div class="more"></div>
    <input type="hidden" name="kid">
    <input type="hidden" name="nextPage">
  </div>
{{--  视频修改弹窗--}}
  <style>
    #videoSave{
      padding:20px 20px 0 20px;;display:none;
    }
    #videoSave input[type="file"]{
      display:none;
    }
    #videoSave table tr td{
      padding:10px;
      white-space: nowrap;
      word-wrap: break-word;
      word-break: break-all;
      color:#777;
      cursor:default;
    }
    #videoSave small,#videoSave .small td{
      color:#FF6666;
    }
    #videoSave img{
      max-width:150px;
      cursor:pointer;
    }
    #removeImg,#removeVideo{
      margin-left:10px;
      display:none;
    }
    #upVideo{
      margin-right:10px;
    }
  </style>
  <div id="showQrcode" style="display:none;padding:20px;"></div>
  <div id="videoSave">
    <form action="" method="post" enctype="multipart/form-data">
      <table>
        <tr>
          <td><small>*</small> 视频标签：</td>
          <td><input class="form-control" type="text" name="title" placeholder="视频标签" maxlength="20"></td>
        </tr>
        <tr>
          <td>上传封面：</td>
          <td>
            <img src="/images/sc.png" id="upImg" title="点击选择图片">
            <a href="javascript:;" class="btn btn-info" id="removeImg">移出</a>
          </td>
          <input type="file" name="img" id="img" onchange="imgChange(this)">
          <input type="hidden" name="oldImg">
        </tr>
        <tr class="small"><td colspan="10">封面大小不能超过5M，只支持png、jpg，可以不传</td></tr>
        <tr>
          <td><small>*</small> 上传视频：</td>
          <td colspan="10">
            <a href="javascript:;" class="btn btn-info btn-sm" id="upVideo">上传视频</a>
            <span class="videoName" title=""></span>
            <a href="javascript:;" class="btn btn-info" id="removeVideo">移出</a>
          </td>
          <input type="file" name="video" id="video" onchange="videoChange(this)">
          <input type="hidden" name="oldVideo">
        </tr>
        <tr class="small"><td colspan="10">视频大小不能超过50M，只支持mp4、webm</td></tr>
        <input type="hidden" name="kid">
      </table>
    </form>
  </div>
{{---------------------------------------------------------------卡券弹窗                                                  --}}
  <style>
    #showcard table {
      border-collapse: collapse;
      color: #777;
      width: 100%;
    }

    #showcard table tr th, #showcard table tr td {
      padding: 10px;
      border: 1px solid #f8f8f8;
      white-space: nowrap
    }

    #showcard table tbody tr:hover {
      background: #f3f3f3;
    }

    #showcard table thead tr {
      background: #f0f0f0;
    }

    #showcard .more {
      text-align: center;
      padding: 10px 0;
    }

    #showcard .more span {
      cursor: pointer;
    }

    #showcard div button {
      padding-right: 20px;
      margin-right: 15px;
    }

  </style>
  <div id="showcard" style="display:none;color:#777;padding:10px 20px 0 20px;">
    <div class="stable-header">
      <div class="form-inline pull-right">
        <fieldset>
          <div class="input-group">
							<span class="input-group-addon">
								<strong>标签</strong>
							</span>
            <input type="text" class="form-control" name="title">
          </div>
          <div class="input-group">
            <button type="button" class="btn btn-primary" onclick="showcardall()">
              <i class="fa fa-search"></i>
            </button>
          </div>
        </fieldset>
      </div>
      <div style="clear:both;"></div>
    </div>
    <table>
      <thead>
      <tr>
        <td>所属会员</td>
        <td>标签</td>
        <td>图片</td>
        <td>类型</td>
        <td>数量</td>
        <td>金额</td>
        <td>使用门槛</td>
        <td>活动介绍</td>
        <td>领取时间</td>
        <td>有效期</td>
        <td>更新时间</td>
        <td>状态</td>
        <td>操作</td>
      </tr>
      </thead>
      <tbody></tbody>
    </table>
    <div class="more"></div>
    <input type="hidden" name="kid">
    <input type="hidden" name="nextPage">
  </div>
{{--*----------------------------卡券弹窗--修改卡券弹窗--}}
  <style>
    #cardSave{
      padding:20px 20px 0 20px;;display:none;
    }
    #cardSave input.form-control,#cardSave select.form-control,#cardSave textarea.form-control{
      width:310px;
      display:inline;
      resize:none;
      color:#777;
      background:#fff;
    }
    #cardSave input[type="file"]{
      display:none;
    }
    #cardSave table tr td{
      padding:10px;
      white-space: nowrap;
      word-wrap: break-word;
      word-break: break-all;
      color:#777;
      cursor:default;
    }
    #cardSave small,#cardSave .small td{
      color:#FF6666;
    }
    #cardSave img{
      width:200px;
      height:90px;
      cursor:pointer;
    }
    #removeImg,#removeVideo{
      margin-left:10px;
      display:none;
    }
    #upVideo{
      margin-right:10px;
    }
  </style>
  <div id="cardSave">
    <form action="" method="post" enctype="multipart/form-data">
      <table>
        <tr>
          <td><small>*</small> 卡券标签：</td>
          <td><input class="form-control" type="text" name="title" placeholder="卡券标签" maxlength="20"></td>
        </tr>
        <tr>
          <td><small>*</small> 上传图片：</td>
          <td>
            <img src="/images/sc.png" id="upImg" title="点击选择图片">
            <a href="javascript:;" class="btn btn-info" id="removeImg">移出</a>
          </td>
          <input type="file" name="img" id="img" onchange="imgChange(this)">
          <input type="hidden" name="oldImg">
        </tr>
        <tr class="small"><td colspan="10">图片大小不能超过5M，只支持png、jpg，尺寸：200px * 90px</td></tr>
        <tr>
          <td><small>*</small> 类型：</td>
          <td>
            <select class="form-control" name="type" placeholder="类型">
              <option value="0">--请选择--</option>
              <option value="1">折扣券</option>
              <option value="2">代金券</option>
              <option value="3">礼品券</option>
            </select>
          </td>
        </tr>
        <tr>
          <td>金额：</td>
          <td><input class="form-control" type="number" name="price" placeholder="金额" maxlength="10"></td>
        </tr>
        <tr class="small"><td colspan="10">金额：选择折扣券、代金券时不填则默认0金额，单位：元</td></tr>
        <tr>
          <td>数量：</td>
          <td><input class="form-control" type="number" name="num" placeholder="数量" maxlength="10"></td>
        </tr>
        <tr class="small"><td colspan="10">卡券数量：不填或者0默认无限制</td></tr>
        <tr>
          <td>使用门槛：</td>
          <td><input class="form-control" type="number" name="cill" placeholder="门槛金额（元）" maxlength="10"></td>
        </tr>
        {{--		<tr>--}}
        {{--			<td>使用门槛：</td>--}}
        {{--			<td><textarea class="form-control" type="text" name="cill" placeholder="使用门槛" maxlength="300"></textarea></td>--}}
        {{--		</tr>--}}
        <tr>
          <td>使用规则：</td>
          <td><textarea class="form-control" type="text" name="remark" rows="4" placeholder="使用规则" maxlength="300"></textarea></td>
        </tr>
        <tr>
          <td><small>*</small> 领取时间：</td>
          <td><input class="form-control dateTime" name="times" placeholder="领取时间"></td>
        </tr>
        <tr>
          <td><small>*</small> 有效时间：</td>
          <td><input class="form-control dateTime" name="valid" placeholder="有效时间"></td>
        </tr>
        <input type="hidden" name="kid">
      </table>
    </form>
  </div>
{{-- ------------------------------------------------------------------------------------ 活动弹窗--}}
  <style>
    #showact table {
      border-collapse: collapse;
      color: #777;
      width: 100%;
    }

    #showact table tr th, #showact table tr td {
      padding: 10px;
      border: 1px solid #f8f8f8;
      white-space: nowrap
    }

    #showact table tbody tr:hover {
      background: #f3f3f3;
    }

    #showact table thead tr {
      background: #f0f0f0;
    }

    #showact .more {
      text-align: center;
      padding: 10px 0;
    }

    #showact .more span {
      cursor: pointer;
    }

    #showact div button {
      padding-right: 20px;
      margin-right: 15px;
    }

  </style>
  <div id="showact" style="display:none;color:#777;padding:10px 20px 0 20px;">
    <div class="stable-header">
      <div class="form-inline pull-right">
        <fieldset>
          <div class="input-group">
							<span class="input-group-addon">
								<strong>标签</strong>
							</span>
            <input type="text" class="form-control" name="title">
          </div>
          <div class="input-group">
            <button type="button" class="btn btn-primary" onclick="showactall()">
              <i class="fa fa-search"></i>
            </button>
          </div>
        </fieldset>
      </div>
      <div style="clear:both;"></div>
    </div>
    <table>
      <thead>
      <tr>
        <td>所属会员</td>
        <td>标题</td>
        <td>活动介绍</td>
        <td>活动时间</td>
        <td>领券数/总数</td>
        <td>转发数</td>
        <td>播放数</td>
        <td>获赞数</td>
        <td>评论数</td>
        <td>分享数</td>
        <td>更新时间</td>
        <td>状态</td>
        <td>审核状态</td>
        <td>操作</td>
      </tr>
      </thead>
      <tbody></tbody>
    </table>
    <div class="more"></div>
    <input type="hidden" name="kid">
    <input type="hidden" name="nextPage">
  </div>
{{--  活动弹窗修改删除相关--}}
  <style>
    #activityHtml{
      color:#777;
    }
    #activityHtml .small,#activityHtml small{
      color:#FF6666;
    }
    #activityHtml table{
      border-collapse: collapse;
      color: #777;
      width:100%;
    }
    #activityHtml table tr td{
      padding: 5px;
      white-space: nowrap;
    }
    #activityHtml table tr td.td-normal{
      max-width:200px;
      white-space: normal;
      word-wrap: break-word;
      word-break: break-all;
    }
    #activityHtml input.form-control,#activityHtml select.form-control,#activityHtml textarea.form-control{
      width:200px;
      display:inline;
      resize:none;
      color:#777;
      background:#fff;
    }
    #activityHtml .imgCard{
      width:200px;
      height:90px;
    }
    #activityHtml .videoUrl{
      width:200px;
      height:100px;
    }


    div.more{
      text-align:center;
    }
    div.more span{
      display:inline-block;
      margin-top:10px;
      color:#777;
      cursor:pointer;
    }
    div.more span:hover{
      color:#999;
    }
  </style>
  <div id="activityHtml" style="padding:20px 20px 0 20px;display:none;">
    <form>
      <table>
        <tr>
          <td><label><small>*</small> 标题：</label></td>
          <td><textarea class="form-control" name="title" placeholder="标题" maxlength="50"></textarea></td>
        </tr>
        <tr class="small"><td>标题如：</td><td class="td-normal">长沙小吃店，好吃一条街</td></tr>
        <tr>
          <td><label>话题：</label></td>
          <td><textarea class="form-control" name="talk" placeholder="话题" maxlength="50"></textarea></td>
        </tr>
        <tr class="small"><td>话题如：</td><td class="td-normal">#话题1&nbsp;&nbsp;&nbsp;#话题2&nbsp;&nbsp;&nbsp;#话题3&nbsp;&nbsp;&nbsp;用空格隔开，最多三个话题</td></tr>
        <tr>
          <td><label>@商户</label></td>
          <td>
            <input class="form-control" type="text" name="openName" placeholder="@商户" readonly>
            <input type="hidden" name="openId">
          </td>
          <td>
            <a href="javascript:;" class="btn btn-info btn-sm" onclick="checkUser(0,0)">选择商户</a>
          </td>
        </tr>
        <tr class="small"><td>@商户：</td><td class="td-normal">如若没有则不选择，谨慎操作以防审核不通过</td></tr>
        <tr>
          <td><label>商户主页：</label></td>
          <td><textarea class="form-control" name="posInurl"></textarea></td>
        </tr>
        <tr class="small"><td>商户主页：</td><td class="td-normal">抖音主页点击分享主页的链接地址<br/>如：https://v.douyin.com/d8Sp5Lh/<br/>没有则不填</td></tr>
        <tr>
          <td><label>商户位置：</label></td>
          <td>
            <textarea class="form-control" name="poiName" placeholder="商户位置" readonly></textarea>
            <input type="hidden" name="poiId">
            <input type="hidden" name="poiAddress">
            <input type="hidden" name="poiCity">
            <input type="hidden" name="pid">
          </td>
          <td>
            <a href="javascript:;" class="btn btn-info btn-sm" onclick="checkAddress(0,0)">搜索位置</a>
          </td>
        </tr>
        <tr class="small"><td>商户位置：</td><td class="td-normal">对应抖音里视频的地理位置如若没有则不选择，对应活动地点</td></tr>
        <tr>
          <td><label><small>*</small> 视频：</label></td>
          <td>
            <video controls class="videoUrl" src=""></video>
            <input type="hidden" name="videoId">
          </td>
          <td>
            <a href="javascript:;" class="btn btn-info btn-sm" onclick="checkVideo(0,0)">选择视频</a>
          </td>
        </tr>
        <tr>
          <td><label>卡券：</label></td>
          <td>
            <img src="/img/no-card.png" class="imgCard">
            <input type="hidden" name="cardId">
          </td>
          <td>
            <a href="javascript:;" class="btn btn-info btn-sm" onclick="checkCard(0,0)">选择卡券</a>
          </td>
        </tr>
        <tr class="small"><td>卡券：</td><td class="td-normal">无卡券纯传播则不选择</td></tr>
        <tr>
          <td><label><small>*</small> 活动介绍：</label></td>
          <td><textarea class="form-control" name="remark" rows="6" placeholder="请填写活动介绍" maxlength="300"></textarea></td>
        </tr>
        <tr>
          <td><label><small>*</small> 活动时间：</label></td>
          <td>
            <textarea class="form-control" name="catyTime" id="catyTime" placeholder="活动时间" readonly></textarea>
          </td>
        </tr>
        <input type="hidden" name="kid" value="">
      </table>
    </form>
  </div>
  <style>
    #h5view{
      width:320px;
      height:600px;
      position:fixed;
      right:10px;
      top:50%;
      margin-top:-300px;
      background:#333333;
      z-index:19891015;
      color:#fff;
      text-align:center;
      padding: 10px;
      border-radius:5px;
    }
    #h5view div.h5-content{
      height:540px;
      overflow-x:hidden;
      overflow-y:auto;
    }
    #h5view div.h5-content::-webkit-scrollbar{
      width:1px;
    }
    #h5view table{
      border-collapse: collapse;
      width:100%;
    }
    #h5view table tr td{
      padding:5px;
      white-space: normal;
      word-wrap: break-word;
      word-break: break-all;
    }
    #h5view .h5{
      color:#FFFF66;
      line-height:1.3;
    }
    #h5view video{
      width:270px;
      height:150px;
    }
    #h5view table tr td.h5-remark{
      max-width:270px;
      color:#DDDDDD;
    }
    #h5view .h5-title{
      color:#FF6666;
    }
    #h5view .h5-time,#h5view .h5-address{
      color:#FF6666;
    }
    #h5view .h5-Card img{
      width:200px;
      height:90px;
    }
    #h5view .compaly{
      color:#FF9966;
    }
    #h5view .bottom a{
      display:inline-block;
      width:135px;
      height:40px;
      margin: 5px;
      line-height:40px;
      border:1px solid transparent;
      border-radius:5px;
      color:#fff;
    }
    #h5view .bottom a.myact{
      background:#555555;
    }
    #h5view .bottom a.mydraw{
      background:#FF6666;
    }
  </style>
  <div id="h5view" style="display:none;">
    <div class="h5-content">
      <table>
        <tr><td class="h5">恭喜~你，获得传播达人资格</td></tr>
        <tr><td style="color:#DDDDDD;">传播的作品</td></tr>
        <tr><td class="h5-title">无</td></tr>
        <tr>
          <td>
            <video controls src=""></video>
          </td>
        </tr>
        <tr>
          <td class="h5-Card"></td>
        </tr>
        <tr><td style="color:#DDDDDD;">活动介绍</td></tr>
        <tr><td class="h5-remark">无</td></tr>
        <tr><td class="h5-address"></td></tr>
        <tr><td class="h5-time">活动时间<br/><span class="catyTime">无</span></td></tr>
        <!--<tr><td class="compaly">云快视</td></tr>-->
      </table>
    </div>
    <div class="bottom">
      <a href="javascript:;" class="myact">我的卡券</a>
      <a href="javascript:;" class="mydraw">传播视频</a>
    </div>
  </div>
  <style>
    #users table tr td,#videos table tr td,#address table tr td{
      padding:10px;
      white-space: nowrap;
      word-wrap: break-word;
      word-break: break-all;
      color:#777;
      cursor:default;
    }
    #users table.users-table{
      width:100%;
    }
    #users table.users-table tr td{
      border:1px solid #f8f8f8;
    }
    #users table.users-table tr:hover{
      background:#f3f3f3;
    }
  </style>
  <div id="users" style="padding:20px 20px 0 20px;;display:none;max-height:500px;">
    <table><tr><td><input class="form-control" type="text" name="userSreach" placeholder="商户名称"></td><td><a href="javascript:;" class="btn btn-info btn-sm" onclick="checkUser(1,0)">搜索</a></td></tr></table>
    <table class="users-table"></table>
    <input type="hidden" name="usersNextPage">
    <div class="more"></div>
  </div>
  <style>
    #videos .videos-body{
      color:#777;
    }
    #videos .videos-body div.video{
      display:block;
      margin:5px;
      border:2px solid transparent;
      float:left;
      padding:5px;
      width:215px;
      height:155px;
      overflow:hidden;
      cursor:pointer;
    }
    #videos .videos-body div video{
      width:200px;
      height:100px;
    }
    #videos .videos-body div.active{
      border-color:#F38F24;
    }
  </style>
  <div id="videos" style="padding:20px 20px 0 20px;;display:none;max-height:640px;max-width:940px;">
    <table><tr><td><input class="form-control" type="text" name="videoSreach" placeholder="视频标签"></td><td><a href="javascript:;" class="btn btn-info btn-sm" onclick="checkVideo(1,0)">搜索</a></td></tr></table>
    <div class="videos-body"></div>
    <input type="hidden" name="videosNextPage">
    <div class="more"></div>
  </div>
  <style>
    #address table.address-table{
      width:100%;
    }
    #address table.address-table thead tr{
      background:#f3f3f3;
    }
    #address table.address-table tr td{
      border:1px solid #f8f8f8;
      padding:10px;
      white-space: normal;
      word-wrap: break-word;
      word-break: break-all;
      color:#777;
      cursor:default;
      max-width:260px;
    }
    #address table.address-table tr:hover{
      background:#f3f3f3;
    }
  </style>
  <div id="address" style="padding:20px 20px 0 20px;;display:none;max-height:500px;">
    <table><tr>
        <td><input class="form-control" type="text" name="nameSearch" placeholder="关键词"></td>
        <td><input class="form-control" type="text" name="citySearch" placeholder="城市"></td>
        <td><a href="javascript:;" class="btn btn-info btn-sm" onclick="checkAddress(1,0)">搜索</a></td>
      </tr></table>
    <table class="address-table">
      <thead>
      <tr>
        <td>编号</td>
        <td>名称</td>
        <td>地址</td>
        <td>城市</td>
      </tr>
      </thead>
      <tbody><tr><td colspan="10">无数据</td></tr></tbody>
    </table>
    <input type="hidden" name="addressNextPage">
    <div class="more"></div>
  </div>
  <style>
    #cards table tr td{
      padding:10px;
      white-space: nowrap;
      word-wrap: break-word;
      word-break: break-all;
      color:#777;
      cursor:default;
    }
    #cards .cards-body{
      color:#777;
    }
    #cards .cards-body div.card{
      display:block;
      margin:5px;
      border:2px solid transparent;
      float:left;
      padding:5px;
      width:215px;
      height:140px;
      overflow:hidden;
      cursor:pointer;
    }
    #cards .cards-body div.card img{
      width:200px;
      height:90px;
    }
    #cards .cards-body div.active{
      border-color:#F38F24;
    }
  </style>
  <div id="cards" style="padding:20px 20px 0 20px;;display:none;max-height:640px;max-width:940px;">
    <table><tr><td><input class="form-control" type="text" name="cardSreach" placeholder="卡券标签"></td><td><a href="javascript:;" class="btn btn-info btn-sm" onclick="checkCard(1,0)">搜索</a></td></tr></table>
    <div class="cards-body"></div>
    <input type="hidden" name="cardsNextPage">
    <div class="more"></div>
  </div>
  <style>
    #tableComment table{
      border-collapse: collapse;
      color: #777;
      width:100%;
    }
    #tableComment table tr th,#tableComment table tr td{
      padding: 10px;
      border: 1px solid #f8f8f8;
      white-space: nowrap
    }
    #tableComment table tbody tr:hover{
      background:#f3f3f3;
    }
    #tableComment table thead tr{
      background: #f0f0f0;
    }
    #tableComment .more{
      text-align:center;
      padding:10px 0;
    }
    #tableComment .more span{
      cursor:pointer;
    }
  </style>
  <div id="tableComment" style="display:none;color:#777;padding:10px 20px 0 20px;">
    <table>
      <thead>
      <tr>
        <td>头像</td>
        <td>用户昵称</td>
        <td>卡卷名称</td>
        <td>卡卷类型</td>
        <td>卡卷金额</td>
        <td>视频地址</td>
        <td>获取时间</td>
        <td>使用状态</td>
        <td>使用时间</td>
      </tr>
      </thead>
      <tbody></tbody>
    </table>
    <div class="more"></div>
    <input type="hidden" name="id">
    <input type="hidden" name="nextPage">
  </div>
  <div id="showQrcode" style="display:none;padding:20px 20px 0 20px;"></div>
@endsection
@section('foot_js')
<script src="{{ asset('/js/jquery.dataTables.min.js') }}"></script>
<script src="{{ asset('/js/dataTables.bootstrap.min.js') }}"></script>
<script src="{{ asset('/js/jquery.slimscroll.min.js') }}"></script>
<script src="{{ asset('/js/fastclick.js') }}"></script>
<script src="{{ asset('/js/tools.js') }}"></script>
<script src="{{ asset('/js/qrcode.min.js') }}"></script>
<script>
var list_ajax;
$(function () {
  //提示信息
  var lang = puppet.langShow();
  //初始化表格
  list_ajax = $("#data_list").dataTable({
    language: lang, //提示信息
    autoWidth: false, //禁用自动调整列宽
    stripeClasses: ["odd", "even"], //为奇偶行加上样式，兼容不支持CSS伪类的场合
    processing: true, //隐藏加载提示,自行处理;
    serverSide: true, //启用服务器端分页
    searching: false, //禁用原生搜索
    //"sSearch": "搜索:",
    orderMulti: false, //启用多列排序
    order: [[0, 'desc']], //取消默认排序查询,否则复选框一列会出现小箭头
    renderer: "bootstrap", //渲染样式：Bootstrap和jquery-ui
    pagingType: "simple_numbers", //分页样式：simple,simple_numbers,full,full_numbers
    aLengthMenu : [10, 20, 50, 100], //更改显示记录数选项
    iDisplayLength:10,
    columnDefs: [
      {
        "targets": [1,2,3,4,5,6,7,8,9], //列的样式名
        "orderable": false    //包含上样式名‘nosort’的禁止排序
      },
    ],
    ajax: function (data, callback, settings) {
      //封装请求参数
      var param = {};
      param.limit = data.length; //页面显示记录条数，在页面显示每页显示多少项的时候
      param.start = data.start; //开始的记录序号
      param.page = (data.start / data.length) + 1; //当前页码
      param.order = data.order;
      param.user_name = $.trim($("#user_name").val());
      param.company = $.trim($("#company").val());
      param.name = $.trim($("#search_name").val());
      param.mobile = $.trim($("#search_mobile").val());
      param.pName = $.trim($("#pName").val());
      $.ajax({
        type: "POST",
        url: "{{ URL('admin/vip/tuoke/ajax') }}",
        cache: false, //禁用缓存
        data: param, //传入组装的参数
        dataType: "json",
        success: function (result) {
          var returnData = {};
          returnData.draw = data.draw; //这里直接自行返回了draw计数器,应该由后台返回
          returnData.recordsTotal = result.total; //返回数据全部记录
          returnData.recordsFiltered = result.total; //后台不实现过滤功能，每次查询均视作全部结果
          returnData.data = result.data; //返回的数据列表
          callback(returnData);
        }
      });
    },
    //列表表头字段
    columns: [
      {"data": "pName"},
      {"data": "createname"},
      {"data": "user_name"},
      {"data": "company"},
      {"data": "indName"},
      {"data": "name"},
      {"data": "mobile"},
      {"data": "create_time"},
      {"data": "status"},
      {"data": "operation"}
    ],
  }).api();
});
//查询指定条件的数据
function searchData(){
    $("#data_list").dataTable().fnDraw(false);
    layer.msg('操作成功',{icon:6});
}
//修改会员状态
function collectionqx(pid){
    var url = "{{URL('admin/company/account/mycollection/editStatus')}}";
    var data = {pid: pid,status:-1};
    var result = puppet.myajax('post', url, data, false);
    if (result.code == 0) {
        // $(obj).prop('type',status_text);
        layer.msg("操作成功",{icon:6,time:1000});
        dataListAjax();
    }else{
        layer.msg("操作失败",{icon:5,time:1000});
    }
}
//查看会员弹窗
function showvipuser(kid,name) {
  layer.closeAll();
  showuser(kid)
  $('#shoucang tbody').html("");
  showlayerArea("showuser", name, "80%", "80%");
}
function showuser(kid, page = 1) {
  var title=$('#showuser input[name="title"]').val();
  $.ajax({
    type: 'POST',
    url: "{{ URL('admin/vip/tuoke/user/ajax') }}",
    data: {kid: kid,title:title,page:page},
    dataType: 'json',
    success: function (r) {
      if (r.code == 1) {
        layer.msg(r.msg, {icon: 5});
        return false;
      }
      if (page == 1) {
        if (r.html == '') {
          $('#showuser tbody').html("<tr><td colspan=\"10\" style=\"text-align:center;\">无数据</td></tr>");
        } else {
          $('#showuser tbody').html(r.msg);
        }
      } else if (page > 1) {
        $('#showuser tbody').append(r.msg);
      }
      if (r.nextPage == 0) {
        $('#showuser .more').html("");
      } else {
        $('#showuser .more').html("<span onclick=\"getMore(kid)\">点击加载更多</span>");
      }
      $('#showuser input[name="kid"]').val(kid);
      $('#showuser input[name="nextPage"]').val(r.nextPage);
    },
    error: function () {
      $('#showuser tbody').html("<tr><td colspan=\"10\" style=\"text-align:center;\">无数据</td></tr>");
      layer.msg("网络错误", {icon: 5});
    }
  });
}
//加载下一页会员用户
function getMore() {
  var nextPage = $('#showuser input[name="nextPage"]').val();
  var kid = $('#showuser input[name="kid"]').val();
  if (nextPage != 0 && nextPage != '' && nextPage != undefined && !isNaN(nextPage)) {
    showuser(kid, nextPage);
  }
}
function showuserall() {
  var kid = $('#showuser input[name="kid"]').val();
  showuser(kid);
}
//--------------------------------------------------------------------------------------------视频相关弹窗js
//查看视频弹窗
function showvipvideo(kid,name) {
  layer.closeAll();
  showvideo(kid)
  $('#showvideo tbody').html("");
  showlayerArea("showvideo", name, "80%", "80%");
}
function showvideo(kid, page = 1) {
  // var kid = $('#tableComment input[name="kid"]').val();
  var title=$('#showvideo input[name="title"]').val();
  $.ajax({
    type: 'POST',
    url: "{{ URL('admin/vip/tuoke/video/ajax') }}",
    data: {kid: kid,title:title,page:page},
    dataType: 'json',
    success: function (r) {
      if (r.code == 1) {
        layer.msg(r.msg, {icon: 5});
        return false;
      }
      if (page == 1) {
        if (r.html == '') {
          $('#showvideo tbody').html("<tr><td colspan=\"10\" style=\"text-align:center;\">无数据</td></tr>");
        } else {
          $('#showvideo tbody').html(r.msg);
        }
      } else if (page > 1) {
        $('#showvideo tbody').append(r.msg);
      }
      if (r.nextPage == 0) {
        $('#showvideo .more').html("");
      } else {
        $('#showvideo .more').html("<span onclick=\"getMorevideo(kid)\">点击加载更多</span>");
      }
      $('#showvideo input[name="kid"]').val(kid);
      $('#showvideo input[name="nextPage"]').val(r.nextPage);
    },
    error: function () {
      $('#showvideo tbody').html("<tr><td colspan=\"10\" style=\"text-align:center;\">无数据</td></tr>");
      layer.msg("网络错误", {icon: 5});
    }
  });
}
//加载下一页会员用户
function getMorevideo() {
  var nextPage = $('#showvideo input[name="nextPage"]').val();
  var kid = $('#showvideo input[name="kid"]').val();
  if (nextPage != 0 && nextPage != '' && nextPage != undefined && !isNaN(nextPage)) {
    showvideo(kid, nextPage);
  }
}
//查询指定标题的视频
  function showvideoall() {
    var kid = $('#showvideo input[name="kid"]').val();
    showvideo(kid);
  }

//添加、修改视频
function showVideo(type){
  var title="";
  if(type==0){
    title="添加视频";
    $('#videoSave input').val('');
    $('#upImg').attr('src','/images/sc.png');
    $('#removeImg').hide();
    $('#videoSave span.videoName').html('');
    $('#removeVideo').hide();
  }else{
    title="修改视频";
  }
  showlayerOne("videoSave",title,videosave,false);
}
//添加、修改视频---提交
function videosave(){
  if($.trim($('#videoSave input[name="title"]').val())==''){
    layer.msg("请填写视频标签",{icon: 5});
    return false;
  }
  var kid=$('#videoSave input[name="kid"]').val();
  var video=$('#video').val();
  if( (kid=='' || kid==null || kid < 1 || kid==undefined || kid=='NaN') && video==''){
    layer.msg("请上传视频",{icon: 5});
    return false;
  }
  var data = new FormData();
  data.append("pid",$('#showvideo input[name="kid"]').val());
  data.append("kid",$('#videoSave input[name="kid"]').val());
  data.append("title",$('#videoSave input[name="title"]').val());
  data.append("img", $('#img')[0].files[0]);
  data.append("video", $('#video')[0].files[0]);
  data.append("oldImg", $('#videoSave input[name="oldImg"]').val());
  data.append("oldVideo", $('#videoSave input[name="oldVideo"]').val());
  // console.log(data);
  $.ajax({
    type:'POST',
    url: "{{ URL('exp/video/save') }}",
    data: data,
    dataType:'json',
    cache: false,//上传文件无需缓存
    processData: false,//用于对data参数进行序列化处理 这里必须false
    contentType: false, //必须
    beforeSend:function(){
      loading_show();
    },
    success:function(r){
      loading_hidden();
      if(r.code==0){
        layer.closeAll();
        layer.msg(r.msg,{icon: 6});
        videoList(0);
      }else{
        layer.msg(r.msg,{icon: 5});
      }
    },
    error:function(){
      loading_hidden();
      layer.msg("网络错误",{icon: 5});
    }
  });
}
//封面选择
$('#upImg').click(function(){
  $('#videoSave input[name="img"]').click();
});
//图片发生改变时
function imgChange(obj){
  if($(obj)[0].files[0]=='' || $(obj)[0].files[0]==null || $(obj)[0].files[0]==undefined || $(obj)[0].files[0]=='NaN'){
    var oldImg=$('#videoSave input[name="oldImg"]').val();
    if(oldImg!='' && oldImg!=null){
      $('#upImg').attr('src',oldImg);
    }else{
      $('#upImg').attr('src','/images/sc.png');
    }
    $('#removeImg').hide();
    return false;
  }
  var this_img=puppet.getObjectURL(obj);
  if ($(obj)[0].files[0]['type'] != 'image/pjpeg' && $(obj)[0].files[0]['type'] != 'image/jpeg' && $(obj)[0].files[0]['type'] != 'image/png' && $(obj)[0].files[0]['type'] != 'image/x-png') {
    layer.msg('封面格式错误', {icon: 5});
  }else if ($(obj)[0].files[0]['size'] > 5242880) {
    layer.msg ('封面不能大于5M', {icon: 5});
    $('#img').val('');
  } else {
    $('#upImg').attr('src',this_img);
    $('#removeImg').show();
  }
}
//移除选择的图片
$('#removeImg').click(function(){
  var oldImg=$('#videoSave input[name="oldImg"]').val();
  if(oldImg!=''){
    $('#upImg').attr('src',oldImg);
  }else{
    $('#upImg').attr('src','/images/sc.png');
  }
  $('#img').val('');
  $('#removeImg').hide();
});
//视频选择
$('#upVideo').click(function(){
  $('#videoSave input[name="video"]').click();
});
//视频发生改变时
function videoChange(obj){
  if($(obj)[0].files[0]=='' || $(obj)[0].files[0]==null || $(obj)[0].files[0]==undefined || $(obj)[0].files[0]=='NaN'){
    var oldVideo=$('#videoSave input[name="oldVideo"]').val();
    if(oldVideo!='' && oldVideo!=null){
      $('#videoSave span.videoName').html(oldVideo);
    }else{
      $('#videoSave span.videoName').html('');
    }
    $('#removeVideo').hide();
    return false;
  }
  var this_img=$(obj)[0].files[0]['name'];
  if ($(obj)[0].files[0]['type'] != 'video/mp4' && $(obj)[0].files[0]['type'] != 'video/webm') {
    layer.msg('视频格式错误', {icon: 5});
  }else if ($(obj)[0].files[0]['size'] > 52428800) {
    layer.msg ('视频不能大于50M', {icon: 5});
    $('#video').val('');
  } else {
    $('#videoSave span.videoName').attr('title',this_img);
    if(this_img.length > 20){
      this_img=this_img.substring(0,10)+"..."+this_img.substring(this_img.length-10);
    }
    $('#videoSave span.videoName').html(this_img);
    $('#removeVideo').show();
  }
}
//移除选择的视频
$('#removeVideo').click(function(){
  var oldVideo=$('#videoSave input[name="oldVideo"]').val();
  if(oldVideo!=''){
    $('#videoSave span.videoName').attr('title',oldVideo);
    if(oldVideo.length > 20){
      oldVideo=oldVideo.substring(0,10)+"..."+oldVideo.substring(oldVideo.length-10);
    }
    $('#videoSave span.videoName').html(oldVideo);
  }else{
    $('#videoSave span.videoName').html('');
  }
  $('#video').val('');
  $('#removeVideo').hide();
});

//修改视频
function videoedit(kid,title,img,video){
  $('#videoSave input[name="kid"]').val(kid);
  $('#videoSave input[name="title"]').val(title);
  $('#videoSave input[name="oldImg"]').val(img);
  $('#videoSave input[name="oldVideo"]').val(video);
  if(img==''){
    $('#upImg').attr('src','/images/sc.png');
  }else{
    $('#upImg').attr('src',img);
  }
  $('#removeImg').hide();
  $('#videoSave span.videoName').attr('title',video);
  if(video.length > 20){
    video=video.substring(0,10)+"..."+video.substring(video.length-10);
  }
  $('#videoSave span.videoName').html(video);
  $('#removeVideo').hide();
  showVideo(1);
}

//修改状态
function videoupStatus(kid,obj){
  var thisType=$(obj).attr("type");
  var pid= $('#showvideo input[name="kid"]').val();
  $.ajax({
    type:'POST',
    url: "{{ URL('exp/video/upStatus') }}",
    data: {kid:kid,pid:pid},
    dataType:'json',
    success:function(r){
      if(r.code==0){
        if(thisType=='checkbox'){
          $(obj).prop('type','default');
          $(obj).prop('checked','');
        }else{
          $(obj).prop('type','checkbox');
          $(obj).prop('checked','checked');
        }
        layer.msg(r.msg,{icon: 6});
      }else{
        layer.msg(r.msg,{icon: 5});
        return false;
      }
    },
    error:function(){
      layer.msg("网络错误",{icon: 5});
      return false;
    }
  });
}

//删除视频
function videodel(kid){
  layer.confirm("是否删除该视频？", {
    skin: "layui-layer-molv",
    btn: ['确认删除', '再考虑一下']
  }, function () {
    $.ajax({
      type:'POST',
      url: "{{ URL('exp/video/del') }}",
      data: {kid:kid},
      dataType:'json',
      success:function(r){
        if(r.code==0){
          layer.msg(r.msg,{icon: 6});
          videoList(0);
        }else{
          layer.msg(r.msg,{icon: 5});
          return false;
        }
      },
      error:function(){
        layer.msg("网络错误",{icon: 5});
        return false;
      }
    });
  }, function () {

  });
}



//---------------------------------------------------------------------------------卡卷弹窗js
function showvipcard(kid,name) {
  layer.closeAll();
  showcard(kid)
  $('#showcard tbody').html("");
  showlayerArea("showcard", name, "80%", "80%");
}
function showcard(kid, page = 1) {
  var title=$('#showcard input[name="title"]').val();
  $.ajax({
    type: 'POST',
    url: "{{ URL('admin/vip/tuoke/card/ajax') }}",
    data: {kid: kid,title:title,page:page},
    dataType: 'json',
    success: function (r) {
      if (r.code == 1) {
        layer.msg(r.msg, {icon: 5});
        return false;
      }
      if (page == 1) {
        if (r.html == '') {
          $('#showcard tbody').html("<tr><td colspan=\"10\" style=\"text-align:center;\">无数据</td></tr>");
        } else {
          $('#showcard tbody').html(r.msg);
        }
      } else if (page > 1) {
        $('#showcard tbody').append(r.msg);
      }
      if (r.nextPage == 0) {
        $('#showcard .more').html("");
      } else {
        $('#showcard .more').html("<span onclick=\"getMorecard(kid)\">点击加载更多</span>");
      }
      $('#showcard input[name="kid"]').val(kid);
      $('#showcard input[name="nextPage"]').val(r.nextPage);
    },
    error: function () {
      $('#showcard tbody').html("<tr><td colspan=\"10\" style=\"text-align:center;\">无数据</td></tr>");
      layer.msg("网络错误", {icon: 5});
    }
  });
}
//加载下一页会员用户
function getMorecard() {
  var nextPage = $('#showcard input[name="nextPage"]').val();
  var kid = $('#showcard input[name="kid"]').val();
  if (nextPage != 0 && nextPage != '' && nextPage != undefined && !isNaN(nextPage)) {
    showcard(kid, nextPage);
  }
}
//查询指定标题的视频
function showcardall() {
  var kid = $('#showcard input[name="kid"]').val();
  showcard(kid);
}

//添加、修改卡卷
function showCard(type){
  var title="";
  if(type==0){
    title="添加卡券";
    $('#cardSave input,#cardSave textarea').val('');
    $('#cardSave select').val(0);
    $('#upImg').attr('src','/images/sc.png');
    $('#removeImg').hide();
  }else{
    title="修改卡券";
  }
  var huodong=layer.open({
    type: 1,
    title: title,
    skin: "layui-layer-molv", //样式类名
    closeBtn: 1, //不显示关闭按钮
    anim: 0,
    shadeClose: false, //开启遮罩关闭
    resize: false, //拉伸关闭
    maxmin: false,
    zIndex: 10000,
    content: $("#cardSave"),
    btn: ["保存","关闭"],
    area: ["auto","80%"],
    yes: function(){
      save();
    }
  });
}
//添加、修改卡券---提交
function save(){
  if($.trim($('#cardSave input[name="title"]').val())==''){
    layer.msg("请填写卡券标签",{icon: 5});
    return false;
  }
  var kid=$('#cardSave input[name="kid"]').val();
  var img=$('#img').val();
  if( (kid=='' || kid==null || kid < 1 || kid==undefined || kid=='NaN') && img==''){
    layer.msg("请上传图片",{icon: 5});
    return false;
  }
  var type=$('#cardSave select[name="type"]').val();
  if(type=='' || type<=0 || type>=4){
    layer.msg("请选择类型",{icon: 5});
    return false;
  }
  var times=$('#cardSave input[name="times"]').val();
  if(times=='' || times==null || times==undefined){
    layer.msg("请选择领取时间",{icon: 5});
    return false;
  }
  var valid=$('#cardSave input[name="valid"]').val();
  if(valid=='' || valid==null || valid==undefined){
    layer.msg("请选择有效时间",{icon: 5});
    return false;
  }
  var data = new FormData();
  data.append("pid",$('#showcard input[name="kid"]').val());
  data.append("kid",$('#cardSave input[name="kid"]').val());
  data.append("title",$('#cardSave input[name="title"]').val());
  data.append("img", $('#img')[0].files[0]);
  data.append("oldImg", $('#cardSave input[name="oldImg"]').val());
  data.append("type", $('#cardSave select[name="type"]').val());
  data.append("price", $('#cardSave input[name="price"]').val());
  data.append("num", $('#cardSave input[name="num"]').val());
  data.append("cill", $('#cardSave input[name="cill"]').val());
  data.append("remark", $('#cardSave textarea[name="remark"]').val());
  data.append("times", $('#cardSave input[name="times"]').val());
  data.append("valid", $('#cardSave input[name="valid"]').val());
  // console.log(data);
  $.ajax({
    type:'POST',
    url: "{{ URL('exp/card/save') }}",
    data: data,
    dataType:'json',
    cache: false,//上传文件无需缓存
    processData: false,//用于对data参数进行序列化处理 这里必须false
    contentType: false, //必须
    beforeSend:function(){
      loading_show();
    },
    success:function(r){
      loading_hidden();
      if(r.code==0){
        layer.closeAll();
        layer.msg(r.msg,{icon: 6});
        cardList(0);
      }else{
        layer.msg(r.msg,{icon: 5});
      }
    },
    error:function(){
      loading_hidden();
      layer.msg("网络错误",{icon: 5});
    }
  });
}
//图片选择
$('#upImg').click(function(){
  $('#cardSave input[name="img"]').click();
});
//图片发生改变时
function imgChange(obj){
  if($(obj)[0].files[0]=='' || $(obj)[0].files[0]==null || $(obj)[0].files[0]==undefined || $(obj)[0].files[0]=='NaN'){
    var oldImg=$('#cardSave input[name="oldImg"]').val();
    if(oldImg!='' && oldImg!=null){
      $('#upImg').attr('src',oldImg);
    }else{
      $('#upImg').attr('src','/images/sc.png');
    }
    $('#removeImg').hide();
    return false;
  }
  var this_img=puppet.getObjectURL(obj);
  if ($(obj)[0].files[0]['type'] != 'image/pjpeg' && $(obj)[0].files[0]['type'] != 'image/jpeg' && $(obj)[0].files[0]['type'] != 'image/png' && $(obj)[0].files[0]['type'] != 'image/x-png') {
    layer.msg('图片格式错误', {icon: 5});
  }else if ($(obj)[0].files[0]['size'] > 5242880) {
    layer.msg ('图片不能大于5M', {icon: 5});
    $('#img').val('');
  } else {
    $('#upImg').attr('src',this_img);
    $('#removeImg').show();
  }
}
//移除选择的图片
$('#removeImg').click(function(){
  var oldImg=$('#cardSave input[name="oldImg"]').val();
  if(oldImg!=''){
    $('#upImg').attr('src',oldImg);
  }else{
    $('#upImg').attr('src','/images/sc.png');
  }
  $('#img').val('');
  $('#removeImg').hide();
});

//修改卡券
function edit(kid,title,type,price,img,num,staTime,endTime,staValid,endValid,obj){
  $('#cardSave input[name="kid"]').val(kid);
  $('#cardSave input[name="title"]').val(title);
  $('#cardSave select[name="type"]').val(type);
  $('#cardSave input[name="price"]').val(price);
  $('#cardSave input[name="oldImg"]').val(img);
  if(img==''){
    $('#upImg').attr('src','/images/sc.png');
  }else{
    $('#upImg').attr('src',img);
  }
  $('#cardSave input[name="num"]').val(num);
  $('#cardSave input[name="times"]').val(staTime+" ~ "+endTime);
  $('#cardSave input[name="valid"]').val(staValid+" ~ "+endValid);
  cill=$(obj).parents('tr').attr('data-cill');
  $('#cardSave textarea[name="cill"]').val(cill);
  remark=$(obj).parents('tr').attr('data-remark');
  $('#cardSave textarea[name="remark"]').val(remark);
  $('#removeImg').hide();
  showCard(1);
}

//时间选择
laydate.render({
  elem: '.dateTime',
  type: 'datetime',
  theme: 'molv',
  range: '~',
  value: ''
});

//修改状态
function upStatus(kid,obj){
  var thisType=$(obj).attr("type");
  var pid = $('#showcard input[name="kid"]').val();
  $.ajax({
    type:'POST',
    url: "{{ URL('exp/card/upStatus') }}",
    data: {kid:kid,pid:pid},
    dataType:'json',
    success:function(r){
      if(r.code==0){
        if(thisType=='checkbox'){
          $(obj).prop('type','default');
          $(obj).prop('checked','');
        }else{
          $(obj).prop('type','checkbox');
          $(obj).prop('checked','checked');
        }
        layer.msg(r.msg,{icon: 6});
      }else{
        layer.msg(r.msg,{icon: 5});
        return false;
      }
    },
    error:function(){
      layer.msg("网络错误",{icon: 5});
      return false;
    }
  });
}

//删除卡券
function del(kid){
  layer.confirm("是否删除该卡券？", {
    skin: "layui-layer-molv",
    btn: ['确认删除', '再考虑一下']
  }, function () {
    $.ajax({
      type:'POST',
      url: "{{ URL('exp/card/del') }}",
      data: {kid:kid},
      dataType:'json',
      success:function(r){
        if(r.code==0){
          layer.msg(r.msg,{icon: 6});
          cardList(0);
        }else{
          layer.msg(r.msg,{icon: 5});
          return false;
        }
      },
      error:function(){
        layer.msg("网络错误",{icon: 5});
        return false;
      }
    });
  }, function () {

  });
}


//-----------------------------------------------------------------------------------活动弹窗js
function showvipact(kid,name) {
  layer.closeAll();
  showact(kid)
  $('#showact tbody').html("");
  showlayerArea("showact", name, "80%", "80%");
}
function showact(kid, page = 1) {
  // var kid = $('#tableComment input[name="kid"]').val();
  var title=$('#showact input[name="title"]').val();
  $.ajax({
    type: 'POST',
    url: "{{ URL('admin/vip/tuoke/act/ajax') }}",
    data: {kid: kid,title:title,page:page},
    dataType: 'json',
    success: function (r) {
      if (r.code == 1) {
        layer.msg(r.msg, {icon: 5});
        return false;
      }
      if (page == 1) {
        if (r.html == '') {
          $('#showact tbody').html("<tr><td colspan=\"10\" style=\"text-align:center;\">无数据</td></tr>");
        } else {
          $('#showact tbody').html(r.msg);
        }
      } else if (page > 1) {
        $('#showact tbody').append(r.msg);
      }
      if (r.nextPage == 0) {
        $('#showact .more').html("");
      } else {
        $('#showact .more').html("<span onclick=\"getMoreact(kid)\">点击加载更多</span>");
      }
      $('#showact input[name="kid"]').val(kid);
      $('#showact input[name="nextPage"]').val(r.nextPage);
    },
    error: function () {
      $('#showact tbody').html("<tr><td colspan=\"10\" style=\"text-align:center;\">无数据</td></tr>");
      layer.msg("网络错误", {icon: 5});
    }
  });
}
//加载下一页会员用户
function getMoreact() {
  var nextPage = $('#showact input[name="nextPage"]').val();
  var kid = $('#showact input[name="kid"]').val();
  if (nextPage != 0 && nextPage != '' && nextPage != undefined && !isNaN(nextPage)) {
    showact(kid, nextPage);
  }
}
//查询指定标题的视频
function showactall() {
  var kid = $('#showact input[name="kid"]').val();
  showact(kid);
}

//修改添加相关页面的js
//添加活动 显示h5活动
function showAity(type){
  var title="添加活动";
  if(type==0){
    $('#activityHtml input,#activityHtml textarea').val('');
    $('#activityHtml .videoUrl').attr('src','');
    $('#activityHtml .imgCard').attr('src','/img/no-card.png');
    $('#h5view .h5-title').html('无');
    $('#h5view video').attr('src','');
    $('#h5view .h5-Card').html('');
    $('#h5view .h5-remark').css({"text-align":"center"}).html('无');
    $('#h5view .h5-address').html('');
    $('#h5view .catyTime').html('无');
  }else{
    title="修改活动";
  }
  var huodong=layer.open({
    type: 1,
    title: title,
    skin: "layui-layer-molv", //样式类名
    closeBtn: 1, //不显示关闭按钮
    anim: 0,
    shadeClose: false, //开启遮罩关闭
    resize: false, //拉伸关闭
    maxmin: false,
    zIndex: 10000,
    content: $("#activityHtml"),
    btn: ["保存","关闭"],
    area: ["auto","80%"],
    yes: function(){
      saveCaty();
    },
    btn2: function(){
      layer.close(huodong);
      $('#h5view').fadeToggle();
    },
    cancel: function(){
      layer.close(huodong);
      $('#h5view').fadeToggle();
    }
  });
  $('#h5view').fadeToggle();
}
//更改标题
$('#activityHtml textarea[name="title"]').keyup(function(){
  var title=$(this).val();
  if($.trim(title)==''){
    $("#h5view .h5-title").html("无");
  }else{
    $("#h5view .h5-title").html($.trim(title));
  }
});
//活动介绍
$('#activityHtml textarea[name="remark"]').keyup(function(){
  var remark=$(this).val();
  if(remark==''){
    $("#h5view .h5-remark").css({"text-align":"center"}).html("无");
  }else{
    remark=remark.replace(/\r\n/g,"<br/>");
    remark=remark.replace(/\n/g,"<br/>");
    remark=remark.replace(/\s/g,"&nbsp;");
    $("#h5view .h5-remark").css({"text-align":"left"}).html(remark+"<br/>注：本活动会在你的抖音中发布该视频");
  }
});

// -------------------------------------------------------------------------------------
//@商户选择 弹出层	isOpen、isMore	0未打开层 or 1已打开、更多
function checkUser(isOpen,isMore){
  var thisOpenId=$('#activityHtml input[name="openId"]').val();
  var userSreach=$('#users input[name="userSreach"]').val();
  var usersNextPage=$('#users input[name="usersNextPage"]').val();
  var pid= $('#showact input[name="kid"]').val();
  if(isMore==0){
    usersNextPage=0;
    $('#users .more').html("");
  }
  $.ajax({
    type:'POST',
    url: "{{ URL('exp/user/list') }}",
    data: {thisOpenId:thisOpenId,usersNextPage:usersNextPage,userSreach:userSreach,pid:pid},
    dataType:'json',
    beforeSend:function(){
      if(isMore==0){
        $('#users .users-table').html('<div style="text-align:center;"><img src="/images/loading.gif"></div>');
      }else{
        $('#users .more').html('<span><img src="/images/loading.gif"></span>');
      }
    },
    success:function(r){
      if(r.code==1){
        layer.msg(r.msg,{icon: 5});
      }else{
        $('#users input[name="usersNextPage"]').val(r.nextPage);
        if(isMore==0){
          $('#users .users-table').html(r.msg);
        }else{
          $('#users .users-table').append(r.msg);
        }
        if(r.nextPage>=2){
          $('#users .more').html("<span onclick='checkUser(1,1)'>点击加载更多</span>");
        }else{
          $('#users .more').html("");
        }
        if(isOpen==0){
          showlayerOne("users","商户选择",selectUser);
        }
      }
    },
    error:function(){
      layer.msg("网络错误",{icon: 5});
    }
  });
}
//确认选择商户
function selectUser(){
  var openId=$('#users input[name="openId"]:checked').val();
  var nickname=$('#users input[name="openId"]:checked').attr('data-name');
  $('#activityHtml input[name="openId"]').val(openId);
  if(openId!=''){
    $('#activityHtml input[name="openName"]').val('@'+nickname);
  }else{
    $('#activityHtml input[name="openName"]').val('');
  }
}

// ------------------------------------------------------------------------------------------------------
//视频选择  弹出层	isOpen、isMore	0未打开层 or 1已打开、更多
function checkVideo(isOpen,isMore){
  var videoId=$('#activityHtml input[name="videoId"]').val();
  var videoSreach=$('#videos input[name="videoSreach"]').val();
  var videosNextPage=$('#videos input[name="videosNextPage"]').val();
  var pid= $('#showact input[name="kid"]').val();
  $('#activityHtml input[name="pid"]').val(pid);
  if(isMore==0){
    videosNextPage=0;
    $('#videos .more').html("");
  }
  $.ajax({
    type:'POST',
    url: "{{ URL('exp/video/list') }}",
    data: {videoId:videoId,videoSreach:videoSreach,videosNextPage:videosNextPage,pid:pid},
    dataType:'json',
    beforeSend:function(){
      if(isMore==0){
        $('#videos .videos-body').html('<div style="text-align:center;"><img src="/images/loading.gif"></div>');
      }else{
        $('#videos .more').html('<span><img src="/images/loading.gif"></span>');
      }
    },
    success:function(r){
      if(r.code==1){
        layer.msg(r.msg,{icon: 5});
      }else{
        $('#videos input[name="videosNextPage"]').val(r.nextPage);
        if(isMore==0){
          $('#videos .videos-body').html(r.msg);
        }else{
          $('#videos .videos-body').append(r.msg);
        }
        if(r.nextPage>=2){
          $('#videos .more').html("<span onclick='checkVideo(1,1)'>点击加载更多</span>");
        }else{
          $('#videos .more').html("");
        }
        if(isOpen==0){
          showlayerOne("videos","视频选择",selectVideo);
        }
      }
    },
    error:function(){
      layer.msg("网络错误",{icon: 5});
    }
  });
}
//确认视频选择
function selectVideo(){
  var videoId=$('#videos .videos-body div.active').attr('data-videoId');
  var videoUrl=$('#videos .videos-body div.active video').attr('src');
  $('#activityHtml input[name="videoId"]').val(videoId);
  $('#activityHtml video.videoUrl').attr('src',videoUrl);
  $('#h5view video').attr('src',videoUrl);
}
//视频鼠标移入事件
function onVideo(obj){
  $(obj).css({"border-color":"#F38F24"});
}
//视频鼠标移出事件
function outVideo(obj){
  if(!$(obj).hasClass('active')){
    $(obj).css({"border-color":"transparent"});
  }
}
//视频鼠标选择事件选择一个div
function dVideo(obj){
  $('#videos .videos-body div.video').removeClass('active').css({"border-color":"transparent"});
  $(obj).addClass('active').css({"border-color":"#F38F24"});
}

// -----------------------------------------------------------------------------------------------------------
//位置搜索接口高德API 搜索位置显示层
function checkAddress(isOpen,isMore){
  var poiId=$('#activityHtml input[name="poiId"]').val();
  var nameSearch=$('#address input[name="nameSearch"]').val();
  var citySearch=$('#address input[name="citySearch"]').val();
  var addressNextPage=$('#address input[name="addressNextPage"]').val();
  var pid= $('#showact input[name="kid"]').val();
  if(isOpen==0){
    showlayerOne("address","位置选择",selectAddress);
    radioAddress(poiId);
    return false;
  }
  if(isMore==0){
    addressNextPage=0;
    $('#address .more').html("");
  }
  $.ajax({
    type:'POST',
    url: "{{ URL('exp/address/list') }}",
    data: {poiId:poiId,nameSearch:nameSearch,citySearch:citySearch,addressNextPage:addressNextPage,pid:pid},
    dataType:'json',
    beforeSend:function(){
      if(isMore==0){
        $('#address .address-table tbody').html('<tr><td colspan="10" style="text-align:center;"><img src="/images/loading.gif"></td></tr>');
      }else{
        $('#address .more').html('<span><img src="/images/loading.gif"></span>');
      }
    },
    success:function(r){
      if(r.code==1){
        layer.msg(r.msg,{icon: 5});
      }else{
        $('#address input[name="addressNextPage"]').val(r.nextPage);
        if(isMore==0){
          $('#address .address-table tbody').html(r.msg);
        }else{
          $('#address .address-table tbody').append(r.msg);
        }
        if(r.nextPage>=2){
          $('#address .more').html("<span onclick='checkAddress(1,1)'>点击加载更多</span>");
        }else{
          $('#address .more').html("");
        }
      }
    },
    error:function(){
      layer.msg("网络错误",{icon: 5});
    }
  });
}
//确认选择地址
function selectAddress(){
  var poiId=$('#address input[name="poiId"]:checked').val();
  var poiName=$('#address input[name="poiId"]:checked').attr('data-name');
  var poiAddress=$('#address input[name="poiId"]:checked').attr('data-address');
  var poiCity=$('#address input[name="poiId"]:checked').attr('data-city');
  $('#activityHtml input[name="poiId"]').val(poiId);
  $('#activityHtml textarea[name="poiName"]').val(poiName);
  $('#activityHtml input[name="poiAddress"]').val(poiAddress);
  $('#activityHtml input[name="poiCity"]').val(poiCity);
  if(poiId!='' && poiId!=null && poiId!=undefined){
    $('#h5view .h5-address').html("活动地点<br/>"+poiName+"<br/>"+poiAddress);
  }else{
    $('#h5view .h5-address').html("");
  }
}
//打开时选中已选择的地址
function radioAddress(poiId){
  var ischeck=false;
  $('#address .address-table tbody tr').each(function(){
    if($(this).find('input').val()==poiId){
      $(this).find('input').prop('checked',true);
      ischeck=true;
    }
  });
  if(ischeck==false && poiId==''){
    $('#address .address-table tbody tr:eq(0) input').prop('checked',true);
  }
}

//-------------------------------------------------------------------------------------------------------------
//卡券选择
function checkCard(isOpen,isMore){
  var cardId=$('#activityHtml input[name="cardId"]').val();
  var cardSreach=$('#cards input[name="cardSreach"]').val();
  var cardsNextPage=$('#cards input[name="cardsNextPage"]').val();
  var pid= $('#showact input[name="kid"]').val();
  if(isMore==0){
    videosNextPage=0;
    $('#cards .more').html("");
  }
  $.ajax({
    type:'POST',
    url: "{{ URL('exp/card/list') }}",
    data: {cardId:cardId,cardSreach:cardSreach,cardsNextPage:cardsNextPage,pid:pid},
    dataType:'json',
    beforeSend:function(){
      if(isMore==0){
        $('#cards .cards-body').html('<div style="text-align:center;"><img src="/images/loading.gif"></div>');
      }else{
        $('#cards .more').html('<span><img src="/images/loading.gif"></span>');
      }
    },
    success:function(r){
      if(r.code==1){
        layer.msg(r.msg,{icon: 5});
      }else{
        $('#cards input[name="cardsNextPage"]').val(r.nextPage);
        if(isMore==0){
          $('#cards .cards-body').html(r.msg);
        }else{
          $('#cards .cards-body').append(r.msg);
        }
        if(r.nextPage>=2){
          $('#cards .more').html("<span onclick='checkCard(1,1)'>点击加载更多</span>");
        }else{
          $('#cards .more').html("");
        }
        if(isOpen==0){
          showlayerOne("cards","视频选择",selectCard);
        }
      }
    },
    error:function(){
      layer.msg("网络错误",{icon: 5});
    }
  });
}
//卡券确认选择事件
function selectCard(){
  var cardId=$('#cards .cards-body div.active').attr('data-cardid');
  var cardUrl=$('#cards .cards-body div.active img').attr('src');
  $('#activityHtml input[name="cardId"]').val(cardId);
  $('#activityHtml img.imgCard').attr('src',cardUrl);
  if(cardId!=''){
    $('#h5view .h5-Card').html('<img src="'+cardUrl+'">');
    $('#h5view .mydraw').html('传播领券');
  }else{
    $('#h5view .h5-Card').html('');
    $('#h5view .mydraw').html('传播视频');
  }
}
//卡券鼠标移入事件
function onCard(obj){
  $(obj).css({"border-color":"#F38F24"});
}
//卡券鼠标移出事件
function outCard(obj){
  if(!$(obj).hasClass('active')){
    $(obj).css({"border-color":"transparent"});
  }
}
//卡券选择事件
function dCard(obj){
  $('#cards .cards-body div.card').removeClass('active').css({"border-color":"transparent"});
  $(obj).addClass('active').css({"border-color":"#F38F24"});
}

//------------------------------------------------------------------------------------------------
//更改活动日期
laydate.render({
  elem: '#catyTime',
  type: 'datetime',
  theme: 'molv',
  range: '~',
  value: '',
  done: function(value,sta,end){
    if(value=='' || value==null || value==undefined){
      $("#h5view .catyTime").html('无');
    }else{
      $("#h5view .catyTime").html(value);
    }
  }
});

//添加修改活动提交
function saveCaty(){
  if($.trim($('#activityHtml textarea[name="title"]').val())==''){
    layer.msg("请填写标题",{icon: 5});
    return false;
  }
  if($.trim($('#activityHtml textarea[name="remark"]').val())==''){
    layer.msg("请填写活动介绍",{icon: 5});
    return false;
  }
  if($.trim($('#activityHtml textarea[name="catyTime"]').val())==''){
    layer.msg("请选择活动时间",{icon: 5});
    return false;
  }
  var pid= $('#showact input[name="kid"]').val();
  $('#activityHtml input[name="pid"]').val(pid);
  var data=$('#activityHtml form').serialize();
  // console.log(data);
  $.ajax({
    type:'POST',
    url: "{{ URL('exp/add/edit') }}",
    data: data,
    dataType:'json',
    beforeSend:function(){
      loading_show();
    },
    success:function(r){
      loading_hidden();
      if(r.code==0){
        layer.closeAll();
        $('#h5view').fadeToggle();
        layer.msg(r.msg,{icon: 6});
        catyList(0);
      }else{
        layer.msg(r.msg,{icon: 5});
      }
    },
    error:function(){
      loading_hidden();
      layer.msg("网络错误",{icon: 5});
    }
  });
}

//修改状态
function upStatus(kid,obj){
  var pid= $('#showact input[name="kid"]').val();
  var thisType=$(obj).attr("type");
  $.ajax({
    type:'POST',
    url: "{{ URL('exp/view/upStatus') }}",
    data: {kid:kid,pid:pid},
    dataType:'json',
    success:function(r){
      if(r.code==0){
        if(thisType=='checkbox'){
          $(obj).prop('type','default');
          $(obj).prop('checked','');
        }else{
          $(obj).prop('type','checkbox');
          $(obj).prop('checked','checked');
        }
        layer.msg(r.msg,{icon: 6});
      }else{
        layer.msg(r.msg,{icon: 5});
        return false;
      }
    },
    error:function(){
      layer.msg("网络错误",{icon: 5});
      return false;
    }
  });
}
//显示、修改活动
function actedit(kid,title,talk,openId,nickname,posInurl,poiName,poiId,poiAddress,poiCity,videoId,cardId,staTime,endTime,vurl,curl,obj){
  $('#h5view .h5-title').html(title);
  $('#h5view video').attr('src',vurl);

  if(cardId!=0){
    $('#h5view .h5-Card').html('<img src="'+curl+'">');
  }
  remark=$(obj).parents('tr').attr('data-remark');
  remarkH5=remark.replace(/\r\n/g,"<br/>");
  remarkH5=remarkH5.replace(/\n/g,"<br/>");
  remarkH5=remarkH5.replace(/\s/g,"&nbsp;");
  $('#h5view .h5-remark').css({"text-align":"left"}).html(remarkH5+"<br/>注：本活动会在你的抖音中发布该视频");
  if(poiId!=''){
    $('#h5view .h5-address').html("活动地点<br/>"+poiName+"<br/>"+poiAddress);
  }
  $('#h5view .catyTime').html(staTime+' ~ '+endTime);
  $('#activityHtml input[name="kid"]').val(kid);
  $('#activityHtml textarea[name="title"]').val(title);
  $('#activityHtml textarea[name="talk"]').val(talk);
  $('#activityHtml input[name="openName"]').val(nickname);
  $('#activityHtml input[name="openId"]').val(openId);
  $('#activityHtml textarea[name="posInurl"]').val(posInurl);
  $('#activityHtml textarea[name="poiName"]').val(poiName);
  $('#activityHtml input[name="poiId"]').val(poiId);
  $('#activityHtml input[name="poiAddress"]').val(poiAddress);
  $('#activityHtml input[name="poiCity"]').val(poiCity);
  $('#activityHtml input[name="videoId"]').val(videoId);
  $('#activityHtml video').attr('src',vurl);
  if(cardId!=0){
    $('#activityHtml input[name="cardId"]').val(cardId);
    $('#activityHtml .imgCard').attr('src',curl);
    $('#h5view .mydraw').html('传播领券');
  }
  $('#activityHtml textarea[name="remark"]').val(remark);
  $('#catyTime').val(staTime+' ~ '+endTime);

  showAity(1);
}
//删除活动
function actdel(kid){
  layer.confirm("是否删除该活动？", {
    skin: "layui-layer-molv",
    btn: ['确认删除', '再考虑一下']
  }, function () {
    var pid= $('#showact input[name="kid"]').val();
    $.ajax({
      type:'POST',
      url: "{{ URL('exp/view/del') }}",
      data: {kid:kid,pid:pid},
      dataType:'json',
      success:function(r){
        if(r.code==0){
          layer.msg(r.msg,{icon: 6});
          catyList(0);
        }else{
          layer.msg(r.msg,{icon: 5});
          return false;
        }
      },
      error:function(){
        layer.msg("网络错误",{icon: 5});
        return false;
      }
    });
  }, function () {

  });
}
//显示卡卷使用情况
function showCardUserinfo(id,title){
  layer.closeAll();
  getVideoComment(id);
  $('#tableComment tbody').html("");
  $('#tableComment .more').html("");
  showlayerArea("tableComment",title,"80%","80%");
}
//拉取视频数据
function getVideoComment(id,page=1){
  $.ajax({
    type:'POST',
    url: "{{ URL('exp/card/userinfo') }}",
    data: {id:id,page:page},
    dataType:'json',
    success:function(r){
      if(r.code==1){
        layer.msg(r.msg,{icon: 5});
        return false;
      }
      if(page==1){
        if(r.html==''){
          $('#tableComment tbody').html("<tr><td colspan=\"10\" style=\"text-align:center;\">无数据</td></tr>");
        }else{
          $('#tableComment tbody').html(r.html);
        }
      }else if(page>1){
        $('#tableComment tbody').append(r.html);
      }
      if(r.nextPage==0){
        $('#tableComment .more').html("");
      }else{
        $('#tableComment .more').html("<span onclick=\"getMoreActvideo()\">点击加载更多</span>");
      }
      $('#tableComment input[name="id"]').val(id);
      $('#tableComment input[name="nextPage"]').val(r.nextPage);
    },
    error:function(){
      $('#tableComment tbody').html("<tr><td colspan=\"10\" style=\"text-align:center;\">无数据</td></tr>");
      layer.msg("网络错误",{icon: 5});
    }
  });
}
//加载下一页评论数据
function getMoreActvideo(){
  var nextPage=$('#tableComment input[name="nextPage"]').val();
  var video_id=$('#tableComment input[name="id"]').val();
  if( nextPage!=0 && nextPage!='' && nextPage!=undefined && !isNaN(nextPage) ){
    getVideoComment(id,nextPage);
  }
}
//关注用户
function following(follow){
  qrCode("showQrcode",follow,"扫码私聊");
}
//修改活动处理状态
function upactStatus(kid,obj){
  var pid= $('#showact input[name="kid"]').val();
  var thisType=$(obj).attr("type");
  $.ajax({
    type:'POST',
    url: "{{ URL('exp/view/upStatus') }}",
    data: {kid:kid,pid:pid},
    dataType:'json',
    success:function(r){
      if(r.code==0){
        if(thisType=='checkbox'){
          $(obj).prop('type','default');
          $(obj).prop('checked','');
        }else{
          $(obj).prop('type','checkbox');
          $(obj).prop('checked','checked');
        }
        layer.msg("操作成功",{icon: 6});
      }else{
        layer.msg("操作失败",{icon: 5});
        return false
      }
    },
    error:function(){
      layer.msg("网络错误",{icon: 5});
      return false;
    }
  });
}
</script>
@endsection